$(function () {
    $.ajax({
        url: "/hospital/record/get/record",
        type: "GET",
        dataType: "json",
        success: function (data) {
           $("#today-count").html(data.length);
           console.log(data.length);
        },
        error: function () {
            alert("数据加载失败!!!");
        }
    });
    $.ajax({
        url: "/hospital/record/get/record1",
        type: "GET",
        dataType: "json",
        success: function (data) {
            $("#all-count").html(data.length);
            console.log(data.length);
        },
        error: function () {
            alert("数据加载失败!!!");
        }
    });
   $("#ulli").click(function () {
       $(".wrap-container welcome-container").css("diaplay","none");
       $(".nowRecordTable").css("display","block");
       $.ajax({
           url: "/hospital/record/get/record",
           type: "GET",
           dataType: "json",
           success: function (data) {
               $("#tbody").html("");
               $.each(data, function (index, ele) {
                   $("#tbody").append(" <tr class='tr' id="+ele.id+">\n" +
                       "        <td>"+ele.patConven+"</td>\n" +
                       "        <td>"+ele.patName+"</td>\n" +
                       "        <td>"+ele.patSex+"</td>\n" +
                       "        <td>"+ele.patAge+"</td>\n" +
                       "        <td>"+ele.patRemark+"</td>\n" +
                       "        <td>"+ele.patContact+"</td>\n" +
                       "        <td>"+ele.patOfcName+"</td>\n" +
                       "        <td>"+ele.patCreatTime+"</td>\n" +
                       "            <td>"+ele.userName+"</td>\n" +
                       "            <td>"+ele.result+"</td>\n" +
                       "            <td>"+ele.remark+"</td>\n" +
                       "        </tr>")
               });
           },
           error: function () {
               alert("数据加载失败!!!");
           }
       });

     })
    $("#ulli2").click(function () {
        $(".wrap-container welcome-container").css("diaplay","none");
        $(".nowRecordTable").css("display","block");
        $.ajax({
            url: "/hospital/record/get/record1",
            type: "GET",
            dataType: "json",
            success: function (data) {
                $("#tbody").html("");
                $.each(data, function (index, ele) {
                    $("#tbody").append(" <tr class='tr' id="+ele.id+">\n" +
                        "        <td>"+ele.patConven+"</td>\n" +
                        "        <td>"+ele.patName+"</td>\n" +
                        "        <td>"+ele.patSex+"</td>\n" +
                        "        <td>"+ele.patAge+"</td>\n" +
                        "        <td>"+ele.patRemark+"</td>\n" +
                        "        <td>"+ele.patContact+"</td>\n" +
                        "        <td>"+ele.patOfcName+"</td>\n" +
                        "        <td>"+ele.patCreatTime+"</td>\n" +
                        "            <td>"+ele.userName+"</td>\n" +
                        "            <td>"+ele.result+"</td>\n" +
                        "            <td>"+ele.remark+"</td>\n" +
                        "        </tr>")
                });
            },
            error: function () {
                alert("数据加载失败!!!");
            }
        });

    })
    //监听表格单击事件
    $("#tbody").on("click",".tr",function () {
        var recId=$(this).attr('id');
     // console.log($(this).children("td").eq(1).html());
     // alert($(this).attr('id'));
     // alert($(this).);
        $("#show-num5").val($(this).children("td").eq(0).html());
        $("#show-name5").val($(this).children("td").eq(1).html());
        $("#show-sex5").val($(this).children("td").eq(2).html());
        $("#show-age5").val($(this).children("td").eq(3).html());
        $("#show-remark5").val($(this).children("td").eq(4).html());
        $("#show-contact5").val($(this).children("td").eq(5).html());
        $("#show-office5").val($(this).children("td").eq(6).html());
        $("#show-time5").val($(this).children("td").eq(7).html());
        $("#show-user5").val($(this).children("td").eq(8).html());
        $("#show-result5").val($(this).children("td").eq(9).html());
        $("#show-remark5").val($(this).children("td").eq(10).html());
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                type: 1,
                area: ['380px', '550px'],
                content: $('#printInfo5') //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            });
        });
        //删除按钮监听
        $("#register-cancel5").click(function () {
            // alert(2);
            $.ajax({
                url: "/hospital/record/delete/record",
                type: "post",
                contentType: "application/json;charset=utf-8",
                dataType: "json",
                data:JSON.stringify({
                    "id":recId,
                }),
                success:function () {
                    layui.use('layer', function(){
                        var layer = layui.layer;
                        layer.msg('删除成功！', {
                            time: 1500, //1.5s后自动关闭
                        });
                    });
                },
                error:function () {
                    layui.use('layer', function(){
                        var layer = layui.layer;
                        layer.msg('删除失败！', {
                            time: 1500, //1.5s后自动关闭
                        });
                    });
                }
            })
        });
    });
   $("#register-back8").click(function () {
       window.location.href("dia-console.html");
   });
});